home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / disk-man / mtools-3.000 / mtools-3 / mtools-3.0 / mtools.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-08  |  4.0 KB  |  147 lines

  1. #ifndef MTOOLS_MTOOLS_H
  2. #define MTOOLS_MTOOLS_H
  3.  
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include "msdos.h"
  7.  
  8. typedef struct device {
  9.     char *name;               /* full path to device */
  10.  
  11.     char drive;               /* the drive letter */
  12.     int fat_bits;        /* FAT encoding scheme */
  13.  
  14.     int mode;               /* any special open() flags */
  15.     unsigned int tracks;    /* tracks */
  16.     unsigned int heads;    /* heads */
  17.     unsigned int sectors;    /* sectors */
  18.  
  19.     long offset;               /* skip this many bytes */
  20.     int use_xdf;
  21.  
  22.     /* internal variables */
  23.     int file_nr;        /* used during parsing */
  24.     unsigned int ssize;
  25.     unsigned int use_2m;
  26.  
  27.     long partition;
  28. } device_t;
  29.  
  30. #include "stream.h"
  31.  
  32.  
  33. extern char *short_illegals, *long_illegals;
  34.  
  35. int maximize(int *target, int max);
  36. int minimize(int *target, int max);
  37.  
  38. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  39.           struct stat *stat);
  40.  
  41. int readwrite_sectors(int fd, /* file descriptor */
  42.               int *drive,
  43.               int rate,
  44.               int seektrack,
  45.               int track, int head, int sector, int size, /* address */
  46.               char *data, 
  47.               int bytes,
  48.               int direction,
  49.               int retries);
  50.  
  51. int lock_dev(int fd);
  52.  
  53. Stream_t *subdir(Stream_t *, char *pathname);
  54.  
  55. char *unix_normalize (char *ans, char *name, char *ext);
  56. void dir_write(Stream_t *Dir, int num, struct directory *dir);
  57. char *dos_name(char *filename, int verbose, int *mangled, char *buffer);
  58. struct directory *mk_entry(char *filename, char attr,
  59.                unsigned int fat, long size, long date,
  60.                struct directory *ndir);
  61. int copyfile(Stream_t *Source, Stream_t *Target);
  62. long getfree(Stream_t *Stream);
  63.  
  64. FILE *opentty(int mode);
  65.  
  66. int is_dir(Stream_t *Dir, char *path);
  67. Stream_t *descend(Stream_t *Dir, Stream_t *Fs, char *path, int barf,
  68.           char *outname);
  69.  
  70. int dir_grow(Stream_t *Dir, Stream_t *Fs, int size);
  71. int match(__const char *, __const char *, char *, int);
  72.  
  73. Stream_t *new_file(char *filename, char attr,
  74.            unsigned int fat, long size, long date,
  75.            struct directory *ndir);
  76. char *unix_name(char *name, char *ext, char Case, char *answer);
  77. void *safe_malloc(size_t size);
  78. Stream_t *open_filter(Stream_t *Next);
  79.  
  80. extern int got_signal;
  81. void setup_signal(void);
  82.  
  83. UNUSED(static inline void set_ulong(unsigned long *address, int value));
  84. static inline void set_ulong(unsigned long *address, int value)
  85. {
  86.     if(value)
  87.         *address = value;
  88. }
  89.  
  90. UNUSED(static inline void set_uint(unsigned int *address, int value));
  91. static inline void set_uint(unsigned int *address, int value)
  92. {
  93.     if(value)
  94.         *address = value;
  95. }
  96.  
  97. UNUSED(static inline int compare (int ref, int testee));
  98. static inline int compare (int ref, int testee)
  99. {
  100.     return (ref && ref != testee);
  101. }
  102.  
  103.  
  104. Stream_t *find_device(char drive, int mode, struct device *out_dev,
  105.               struct bootsector *boot,
  106.               char *name, int *media);
  107.  
  108. struct directory *labelit(char *dosname,
  109.               char *longname,
  110.               void *arg0,
  111.               struct directory *dir);
  112.  
  113. char *label_name(char *filename, int verbose, 
  114.          int *mangled, char *ans);
  115.  
  116. void cleanup_and_exit(int code);
  117. /* environmental variables */
  118. extern int mtools_skip_check;
  119. extern int mtools_fat_compatibility;
  120. extern int mtools_ignore_short_case;
  121. extern int mtools_rate_0, mtools_rate_any, mtools_raw_tty;
  122.  
  123. void read_config(void);
  124. extern struct device *devices;
  125. extern struct device const_devices[];
  126. extern const nr_const_devices;
  127.  
  128. #define New(type) ((type*)(malloc(sizeof(type))))
  129. #define Grow(adr,n,type) ((type*)(realloc((char *)adr,n*sizeof(type))))
  130. #define Free(adr) (free((char *)adr));
  131. #define NewArray(size,type) ((type*)(calloc((size),sizeof(type))))
  132.  
  133. void mattrib(int argc, char **argv, int type);
  134. void mbadblocks(int argc, char **argv, int type);
  135. void mcd(int argc, char **argv, int type);
  136. void mcopy(int argc, char **argv, int type);
  137. void mdel(int argc, char **argv, int type);
  138. void mdir(int argc, char **argv, int type);
  139. void mformat(int argc, char **argv, int type);
  140. void mlabel(int argc, char **argv, int type);
  141. void mmd(int argc, char **argv, int type);
  142. void mmount(int argc, char **argv, int type);
  143. void mmove(int argc, char **argv, int type);
  144. void mtest(int argc, char **argv, int type);
  145.  
  146. #endif
  147.